%% FIGURE 9
clear all
clc
% Add path 
% Determine where your m-file's folder is.
folder = fileparts(which("Figure_9.m")); 
% Add that folder plus all subfolders to the path.
addpath(genpath(folder)); 

% Saving path
file_dir = what('Figures'); 
spath=file_dir.path;

% Setting
hor=24;
jhor=0:hor;
Run_color_settings
% LOAD DATA
load("Results/Empi_App.mat");
var_names={'Real DGP','GDP Deflator','Consumption','Investment','Hours Worked','Wages','Federal Funds Rate',};


% Plot
clf
N_var=7;
labelsize=14;
N_plot=N_var;
pln=1;
plotColumns=2;
figure(1)
for j=1:N_plot
            
            grid on
            pl=subplot(ceil(N_plot/plotColumns),plotColumns,pln);
            hold on
            
            % Confidence band   
            fill([0:1:hor, fliplr(0:1:hor)],...
                [Results.IRF_Pool_LB_bootrep(j,1:hor+1) fliplr(Results.IRF_Pool_UB_bootrep(j,1:hor+1))],...
               SBBbandFillColor,'EdgeColor','none','FaceAlpha',0.5); 

            fill([0:1:hor, fliplr(0:1:hor)],...
                [Results.IRF_Pool_LB_seqblock(j,1:hor+1) fliplr(Results.IRF_Pool_UB_seqblock(j,1:hor+1))],...
                RBBbandFillColor,'EdgeColor','none','FaceAlpha',0.5);
            
                       
                    
            % IRFs
            p0=plot(jhor,Results.IRF_VAR(j,:), '--','LineWidth',3,'Color', line_colors(1,:)); 
            p1=plot(jhor,Results.IRF_LP(j,:), '-.','LineWidth',3,'Color', line_colors(2,:)); 
            p2=plot(jhor,Results.IRF_Pool(j,:), '-','LineWidth',3,'Color', line_colors(3,:)); 
            
          
            % Zero line
            plot(0:hor,zeros(size(1:hor+1)),'k')
            hold off; axis tight
            xlim([0 hor]);
            set(gca,'XTick',0:4:hor,'XTickLabel',cellstr(num2str((0:4:hor)')),'Layer','top','FontSize',14)
           
                if j==1
                ylabel('% point','FontSize',labelsize)
                xlabel('Quarter','FontSize',labelsize)  
                elseif j==2
                xlabel('Quarter','FontSize',labelsize)   
                ylabel('% point','FontSize',labelsize)          
                lh=legend([p0 p1 p2],{'VAR';'LP';'Pool'},'FontSize',13,'Location','southwest','Box','off');
               elseif j==3
                xlabel('Quarter','FontSize',labelsize)   
                ylabel('% point','FontSize',labelsize)        
               elseif j==4
                xlabel('Quarter','FontSize',labelsize)   
                ylabel('% point','FontSize',labelsize)        
               elseif j==5
                xlabel('Quarter','FontSize',labelsize)   
                ylabel('% point','FontSize',labelsize)       
               elseif j==6
                xlabel('Quarter','FontSize',labelsize)   
                ylabel('% point','FontSize',labelsize)       
               elseif j==7
                xlabel('Quarter','FontSize',labelsize)   
                ylabel('Index point','FontSize',labelsize)       
                end
            title([var_names{j}],'FontSize',16,'FontWeight','normal')
            grid on
            ax = gca;             % Get current axes
            ax.GridLineStyle = ':';    % (Optional) Set grid line style
            ax.LineWidth = 1.5;         % This affects grid line thickness and axes box
            ax.GridColor = [0 0 0];
            x0=10;
            y0=10;
            width=800;
            height=900;
            pln=pln+1;          
            set(gcf,'position',[x0,y0,width,height])          
 end
saveas(figure(1),fullfile(spath,['EmpApp.eps']),'epsc');
